﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentDemoP18_4 {
    internal class Program {
        static void Main(string[] args) {
            Student outStu = new Student() { Name = "Tim"};
            Console.WriteLine("HashCode={0},Name={1}", outStu.GetHashCode(), outStu.Name);
            Console.WriteLine("====================");
            IWantSideEffect(ref outStu);
            Console.WriteLine("HashCode={0},Name={1}", outStu.GetHashCode(), outStu.Name);
            Console.ReadLine();
            /**
             * 上面执行结果为：
             * HashCode=46104728,Name=Tim
                ====================
                HashCode=12289376,Name=Tom
                HashCode=12289376,Name=Tom
            下面2个因为是直接的引用传递，所以指向的地址值是一样的
             */
        }

        static void IWantSideEffect(ref Student stu) {
            stu = new Student() { Name = "Tom"};
            Console.WriteLine("HashCode={0},Name={1}",stu.GetHashCode(),stu.Name);

        }
    }

    class Student { 
        public string Name { get; set; }
    }
}
